package com.qf.service.impl;

import com.qf.dao.AccountDao;
import com.qf.service.AccountService;
import com.qf.test.InterfaceTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * @author YDW
 * projectName:project2202_3
 * time:2022/5/6 11:44
 * description:
 */
@Service("accountService")
//@Scope("SINGLETON")
//@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,readOnly = true,rollbackFor = Exception.class)
public class AccountServiceImpl implements AccountService {

//    @Autowired(required = false)
//    @Qualifier("InterfaceTestImplA")
//    @Resource(name="interfaceTestImplA")
//    InterfaceTest interfaceTest;
    @Autowired
    AccountDao accountDao;

//    @PostConstruct
//    @PreDestroy
    public void setAccountDao(AccountDao accountDao) {
        this.accountDao = accountDao;
    }

    @Override
    @Transactional
    public void transfer(Integer fromId, Integer toId, Double money)  {
        accountDao.losemoney(fromId,money);
//        int i=1/0;
        accountDao.getmoney(toId,money);
    }
}
